package com.zn.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.zn.mapper.ServiceRecordMapper;
import com.zn.pojo.ServiceRecord;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Description
 * @Author zhaoning
 * @Date 2024/7/19
 */
@Service
public class ServiceRecordServiceImpl implements com.zn.service.ServiceRecordService {

    @Resource
    private ServiceRecordMapper serviceRecordMapper;

    @Override
    public List<ServiceRecord> selectAllServiceRecord() {
        QueryWrapper<ServiceRecord> queryWrapper = new QueryWrapper<>();

        return serviceRecordMapper.selectList(queryWrapper);
    }

    @Override
    public List<ServiceRecord> selectById(Integer id) {
        QueryWrapper<ServiceRecord> res = new QueryWrapper<>();
        res.eq("to_id", id);

        return serviceRecordMapper.selectList(res);
    }



    @Override
    public ServiceRecord save(ServiceRecord serviceRecord) {
        ServiceRecord newServiceRecord;
        int isInsert = serviceRecordMapper.insert(serviceRecord);
        if (isInsert > 0) {
            newServiceRecord = serviceRecord;
        } else {
            newServiceRecord = null;
        }

        return newServiceRecord;
    }
}
